﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using Castle.ActiveRecord;
using System.Web.UI;
using System.IO;
using SimplePMT.Data;
using SimplePMT.Components;
using NHibernate.Expression;

namespace SimplePMT.Control
{
    public partial class QAReportControl : System.Web.UI.UserControl
    {
        public string project = string.Empty;
        public string releaseNumber = string.Empty;
        public bool edit = false;
        public int reportId = 0;
        public QAReport qaReport;
        public string reportTitle = "";

        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        public override string ToString()
        {
            Release[] r = Release.FindAllByProperty("QAReportID", reportId);
            if (!r.Length.Equals(0)) {
                TaskContainer container = TaskContainer.Find(r[0].TaskContainerID);
                project = container.Label;
                releaseNumber = r[0].Major + "." + r[0].Minor + "." + r[0].Build;
            }

            bool ReadOnly = false;
            if (Session["MemberID"] != null)
            {
                Member member = Member.Find(Convert.ToInt32(Session["MemberID"]));
                ReadOnly = member.ReadOnly;
            }
            
            using (new SessionScope())
            {
                qaReport = QAReport.Find(reportId) ?? new QAReport();
            }

            string result = "";
            StringWriter writer = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
            this.Render(htmlWriter);
            result = writer.ToString();
            return result;
        }
    }
}